package fonkin.com.wifisignapp.utils;

import android.content.Context;
import android.view.Gravity;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;

/**
 * Created by 黄洪靖 on 2017/4/11.
 */

public class ShowToast {
    public static Toast toast;

    /**
     * 显示长时间的Toast
     * @param str
     * @param context
     */
    public static void ShowToastShort(String str, Context context){
        toast= Toast.makeText(context, str, Toast.LENGTH_SHORT);
        toast.show();

    }

    /**
     * 显示长时间的Toast
     * @param str
     * @param context
     */
    public static void ShowToastLong(String str, Context context){

        toast=Toast.makeText(context, str, Toast.LENGTH_LONG);
        toast.show();
    }

    /**
     *显示在中间的Toast
     * @param str
     * @param context
     */
    public static void CenterToast(String str,Context context){
        toast=Toast.makeText(context, str, Toast.LENGTH_LONG);
        toast.setGravity(Gravity.CENTER,0,0);
        toast.show();
    }

    /**
     *显示在中间的自定义图片的Toast
     * @param str
     * @param context
     */
    public static void CenterPicToast(String str, Context context, int i){
        toast=Toast.makeText(context, str, Toast.LENGTH_LONG);
        toast.setGravity(Gravity.CENTER,0,0);
       LinearLayout liner = (LinearLayout)toast.getView();
        ImageView image = new ImageView(context);
        image.setImageResource(i);
        liner.addView(image,0);
        toast.show();

    }


}
